Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

taprpc: decimal display requires JSON meta #983

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

jharveyb
Copy link
Contributor

Follow-on to #979 .

For minting via RPC, there was a missing check to prevent the decimal display value from being dropped before reaching the minter.

In this commit, we require an asset request with a custom decimal
display to have a non-empty meta field. Without this check, the asset
would be created with no metadata and therefore have the default decimal
display value of 0.
@jharveyb jharveyb requested review from ffranr, Roasbeef and GeorgeTsagk and removed request for Roasbeef June 27, 2024 20:30
@dstadulis dstadulis added this to the v0.4 milestone Jun 28, 2024
itest/asset_meta_test.go Show resolved Hide resolved
// If a custom decimal display is set, the meta type must also be set to
// JSON.
if req.Asset.DecimalDisplay != 0 && req.Asset.AssetMeta == nil {
return nil, fmt.Errorf("decimal display requires JSON asset " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to instead bootstrap the meta json with just the decimal display field? otherwise a user will have to provide an empty json {} for this to work, which might not be intuitive

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with setting to an empty meta json if the meta field nil in the request but a decimal display is given.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AssetMeta field here is both Data and Type. So we require Type to be set t JSON for decimal display to get set as the only JSON field if the metadata data field was empty.

Was implemented in #979 , seen here:

if metaType == proof.MetaJson && req.Asset.DecimalDisplay != 0 {

This check is added before that bootstrapping to enforce that the user at least set the correct metadata type.

Copy link
Contributor

@ffranr ffranr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do this: 5fa519d#r1658411119

And then should be good to go.

// If a custom decimal display is set, the meta type must also be set to
// JSON.
if req.Asset.DecimalDisplay != 0 && req.Asset.AssetMeta == nil {
return nil, fmt.Errorf("decimal display requires JSON asset " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with setting to an empty meta json if the meta field nil in the request but a decimal display is given.

@jharveyb jharveyb added this pull request to the merge queue Jul 1, 2024
Merged via the queue into main with commit 9bd0b75 Jul 1, 2024
16 checks passed
@guggero guggero deleted the dec_display_require_meta branch July 8, 2024 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants